package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.WorkflowBusinessUserRel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2020-12-08 10:50:34
 */
@Repository
public class WorkflowBusinessUserRelDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(WorkflowBusinessUserRelDao.class);

    public WorkflowBusinessUserRel insert(final WorkflowBusinessUserRel workflowBusinessUserRel) {
        insert("WorkflowBusinessUserRel.insert", workflowBusinessUserRel);
        return workflowBusinessUserRel;
    }

    public Boolean updateInfoById(final WorkflowBusinessUserRel workflowBusinessUserRel) {
        return update("WorkflowBusinessUserRel.updateInfoById", workflowBusinessUserRel) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("WorkflowBusinessUserRel.updateInfoByQuery", query) > 0;
    }

    public WorkflowBusinessUserRel selectById(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return queryForObject("WorkflowBusinessUserRel.selectById", query);
    }

    public List<WorkflowBusinessUserRel> selectByQuery(final Query query) {
        return queryForList("WorkflowBusinessUserRel.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("WorkflowBusinessUserRel.countByQuery", query);
    }

    public Boolean deleteById(final Integer id) {
        WorkflowBusinessUserRel workflowBusinessUserRel = new WorkflowBusinessUserRel();
        workflowBusinessUserRel.setDeleteFlag(1);
        workflowBusinessUserRel.setId(id);

        return update("WorkflowBusinessUserRel.updateInfoById", workflowBusinessUserRel) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("WorkflowBusinessUserRel.deleteById", query) > 0;
    }
}